/* 接口返回统一设置 */
function routerResponse(option={}){
    return async function(ctx,next){
        ctx.success = function (data,msg,total) {
            ctx.type = option.type || 'json'
            ctx.body = {
                code : option.successCode || 200,
                msg : msg,
                data : data,
                total:total
            }
        }
        ctx.fail = function (msg,code) {
            ctx.type = option.type || 'json'
            ctx.body = {
                code : code || option.failCode || -1,
                msg : msg || option.successMsg || 'fail',
            }
        }
       await next()
    }
}
module.exports = routerResponse